<!-- 选择模块 -->

<script type="text/javascript">
$(function(){
	$(".tabs[aria-hidden='false'] .modules_select").die().live("change",function(){
		createSelect($(this));
	})
	//联动
	function createSelect(element){
		var selected=element.find("option:selected");
		var leaf=selected.attr("leaf");
		//清除后面的元素
		element.nextAll().remove();
		if(leaf==1){
			return false;
		}else{
			$.post(BASE+"/admin/content/get_modules",{"mid":element.val(),"level":selected.attr("level")},function(data){
				if(!isEmpty(data)){
					element.after("<select class='modules_select'></select>");
					$.each(data,function(i,d){
						$(".modules_select:last").append("<option value='"+d.id+"' leaf='"+d.module_leaf+"' level='"+d.module_level+"'>"+d.name+"</option>")
					});
					createSelect($(".modules_select:last"));
				}
			},"json");
		}
	}
	//初始化
	createSelect($(".modules_select:last"));
});
</script>

<span class="modules_container">
	<select class="modules_select">
		<!-- 给与首层链接的特权 -->
		<foreach name="module" item="m">
			<if condition="$m['contents'] eq 1 and $m['module_level'] eq 1">
				<option value="{$m.id}" leaf="{$m.module_leaf}" level="{$m.module_level}">{$m.name}</option>
			</if>
		</foreach>
	</select>
</span>
